
LIB=blacklib
TMPDIR = tmp
INCLUDEDIR = include
SRCDIR = src
LIBDIR = lib
SRC= $(wildcard $(SRCDIR)/*.cpp)
OBJ= $(SRC:$(SRCDIR)/%.cpp=$(TMPDIR)/%.o)

all: prepare $(LIB)

prepare:
	@-mkdir $(TMPDIR)
	@-mkdir $(LIBDIR)

$(LIB): $(OBJ)
	@echo [[ link $@, $^
	@ar rcs $(LIBDIR)/lib$(LIB).a $^ $(LDFLAGS)
	
$(TMPDIR)/%.o: $(SRCDIR)/%.cpp
	@echo [[ compile $@, $<
	@$(CC) -I$(INCLUDEDIR) -o $@ -c $< $(CFLAGS)
	
.PHONY: clean

clean:
	@-rm -rf $(TMPDIR)
	@-rm -rf $(LIBDIR)